﻿using System;
using System.Collections.Generic;

class MaxIncreasingSequence

            // Write a program that finds the maximal increasing sequence in an array. Example: {3, 2, 3, 4, 2, 2, 4}  {2, 3, 4}.

{
    static void Main()
    {
        Console.Write("Enter the length of the array: ");
        int arraySize = int.Parse(Console.ReadLine());
        int[] arr = new int[arraySize];
        Console.WriteLine();

        Console.WriteLine("Enter the elements of the array:");
        for (int i = 0; i < arraySize; i++)
        {
            arr[i] = int.Parse(Console.ReadLine());
        }

        List<int> numArray = new List<int>();
        int lenght = 0;
        int bestLenght = 1;
        for (int i = 0; i < arr.Length - 1; i++)
        {
            if (arr[i] == (arr[i + 1] - 1))
            {
                lenght++;
                if (lenght > bestLenght)
                {
                    bestLenght = lenght;
                    numArray.Clear();
                    arr[i] -= lenght;
                    for (int k = 0; k <= lenght; k++)
                    {
                        arr[i]++;
                        numArray.Add(arr[i]);
                    }
                }
            }
            else
            {
                lenght = 0;
            }
        }
        string str = string.Join(",", numArray);
        Console.WriteLine("The maximal increasing sequance is: {0}", str);
    }
}

